

<template>
  <div style="width: fit-content">
    <el-row>
      <template v-for="(btn, i) in m_List">
        <el-button class="home-top-tab-btn" @click="click(btn.name)" v-if="$verifyPerms(btn.code)" :key="i" type="info" size="mini" plain>{{ btn.name }}</el-button>
      </template>
    </el-row>
    <AddWork ref="addWork"></AddWork>
    <data-list :istable="false" ref="dataList"></data-list>
    <el-dialog :visible.sync="m_NualPlan.vsb" title="变更年度计划" width="30%" :close-on-click-modal="false">
      <el-form label-width="150px" size="small" label-position="right">
        <el-form-item label="选择年份">
          <el-date-picker v-model="m_NualPlan.date" type="year" placeholder="选择年"> </el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="m_NualPlan.vsb = false">取 消</el-button>
        <el-button size="small" type="primary" @click="save">保存</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import dayjs from 'dayjs';
import AddWork from '@/pages/businessAssets/pages/workTrace/components/addWork';
import dataList from '@/pages/businessPlan/pages/businessManagementOperation/components/dataList';
export default {
  components: { AddWork, dataList },
  data() {
    return {
      m_List: [
        {
          name: '变更年度计划',
          code: 'changeAnnualPlan',
        },
        {
          name: '发起年度计划',
          code: 'initiateAnAnnualPlan',
        },
        {
          name: '新建会议纪要',
          code: 'newMeetingMinutes',
        },
        {
          name: '新建工作',
          code: 'newJob',
        },
        {
          name: '查看已办',
          code: 'viewDone',
        },
      ],
      m_NualPlan: {
        vsb: false,
        date: null,
      },
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //接收参数
  props: {},
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  //方法集合
  methods: {
    click(res) {
      let url = null;
      console.log(res)
      if (res == '新建工作') {
        this.$refs['addWork'].init()
      }
      if (res == '新建会议纪要') {
        url = '/businessAssets/trace/summaryInfo';
      }
      if (res == '发起年度计划') {
        this.$refs.dataList.editItem();
      }
      if (res == '变更年度计划') {
        this.m_NualPlan.vsb = true;
      }
      if (res == '查看已办') {
        url = '/businessAssets/trace/haveDone?menuId=63a745412b374be1825b38731ca55105&parentMenuId=7ee2400d0e72437aa3bdb5823497537f&timestamp=1654065479275&TAB=3&tabId=367ca9dce769449f97b600172222a93b';
      }
      if (url) window.open(url);
    },
    save() {
      if (!this.m_NualPlan.date) {
        this.$message.warning('请选择年份');
        return;
      }
      window.ajaxFinancialplan.request(`/v1/business/PlanCompile/editYearPlan`, 'post', { planYear: new Date(this.m_NualPlan.date).getFullYear() }, { showLoading: true }).then(res => {
        if (res.success) {
          this.$message.success(res.message);
          this.m_NualPlanvsb = false;
        } else {
          this.$message.warning(res.message);
        }
      });
    },
  },
};
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>